Source Code Viewer - Example 9 - ViewPairConversionsAction

package name.matthewgreet.example9.action;

import org.apache.struts2.ActionSupport;
import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.InterceptorRef;
import org.apache.struts2.convention.annotation.Result;
import org.apache.struts2.convention.annotation.Results;

import name.matthewgreet.example9.form.DateOfBirthPairConversionForm;
import name.matthewgreet.example9.form.FlagPairConversionForm;
import name.matthewgreet.example9.form.RatingPairConversionForm;
import name.matthewgreet.example9.form.RequiredPricePairConversionForm;
import name.matthewgreet.example9.form.RequiredScorePairConversionForm;
import name.matthewgreet.example9.form.TechAttitudePairConversionForm;
import name.matthewgreet.example9.view.AttitudeSelectBoxDisplay;
import name.matthewgreet.example9.view.RatingSelectBoxDisplay;
import name.matthewgreet.example9.view.TechCompanySelectBoxDisplay;
import name.matthewgreet.strutscommons.action.AbstractViewActionSupport;


/**
 * Displays tests of string, formatted fields converted to non-string, unformatted fields.  
 */
@InterceptorRef("ViewStack")
@Results({
	@Result(name=ActionSupport.SUCCESS, location="/pages/PairConversions.jsp")
})
public class ViewPairConversionsAction extends AbstractViewActionSupport {
	private static final long serialVersionUID = -7979376337555804889L;
	
	private RequiredScorePairConversionForm requiredScoreForm;
	private FlagPairConversionForm flagForm;
	private DateOfBirthPairConversionForm dateOfBirthForm;
	private RatingPairConversionForm ratingForm;
	private TechAttitudePairConversionForm techAttitudeForm;
	private RequiredPricePairConversionForm requiredPriceForm;

	private RatingSelectBoxDisplay ratingSelectBoxDisplay;
	private TechCompanySelectBoxDisplay techCompanySelectBoxDisplay;
	private AttitudeSelectBoxDisplay attitudeSelectBoxDisplay;

	
    @Action("/ViewPairConversion")
    @Override
    public String execute() throws Exception {
    	if (requiredScoreForm == null) {
    		requiredScoreForm = new RequiredScorePairConversionForm();
    	}
    	if (flagForm == null) {
    		flagForm = new FlagPairConversionForm();
    	}
    	if (dateOfBirthForm == null) {
    		dateOfBirthForm = new DateOfBirthPairConversionForm();
    	}
    	if (ratingForm == null) {
    		ratingForm = new RatingPairConversionForm();
    	}
    	if (techAttitudeForm == null) {
    		techAttitudeForm = new TechAttitudePairConversionForm();
    	}
    	if (requiredPriceForm == null) {
    		requiredPriceForm = new RequiredPricePairConversionForm();
    	}
	    
    	ratingSelectBoxDisplay = new RatingSelectBoxDisplay();
    	ratingSelectBoxDisplay.setSelectedFormattedValue(ratingForm.getRating());
    	techCompanySelectBoxDisplay = new TechCompanySelectBoxDisplay();
    	techCompanySelectBoxDisplay.setSelectedFormattedValue(techAttitudeForm.getTechCompany());
    	attitudeSelectBoxDisplay = new AttitudeSelectBoxDisplay();
    	attitudeSelectBoxDisplay.setSelectedFormattedValue(techAttitudeForm.getAttitude());
        
		return SUCCESS;
    }

	public RequiredScorePairConversionForm getRequiredScoreForm() {
		return requiredScoreForm;
	}
	public FlagPairConversionForm getFlagForm() {
		return flagForm;
	}
	public DateOfBirthPairConversionForm getDateOfBirthForm() {
		return dateOfBirthForm;
	}
	public RatingPairConversionForm getRatingForm() {
		return ratingForm;
	}
	public TechAttitudePairConversionForm getTechAttitudeForm() {
		return techAttitudeForm;
	}
	public RequiredPricePairConversionForm getRequiredPriceForm() {
		return requiredPriceForm;
	}

	public RatingSelectBoxDisplay getRatingSelectBoxDisplay() {
		return ratingSelectBoxDisplay;
	}
	public TechCompanySelectBoxDisplay getTechCompanySelectBoxDisplay() {
		return techCompanySelectBoxDisplay;
	}
	public AttitudeSelectBoxDisplay getAttitudeSelectBoxDisplay() {
		return attitudeSelectBoxDisplay;
	}

}